using JT808Protocol.Common;
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace JT808Protocol.Models.BodyParserStrategy.CommonResponse
{
    /// <summary>
    /// 终端通用应答
    /// </summary>
    public class DpCommon_0x0001 : IJT808Body
    {
        /// <summary>
        /// 应答流水号
        /// </summary>
        [JsonPropertyName("应答流水号")] public ushort SerialNum { get; set; }

        /// <summary>
        /// 应答ID
        /// </summary>
        [JsonPropertyName("应答ID")] public ushort ID { get; set; }

        /// <summary>
        /// 结果
        /// </summary>
        [JsonPropertyName("结果")] public EnumResult Result { get; set; }

        public override IJT808Body ReadBody(ReadOnlySpan<byte> data, ref int index)
        {
            SerialNum = ParseHelper.Uint16(ref data, index);
            index += 2;
            ID = ParseHelper.Uint16(ref data, index);
            index += 2;
            Result = (EnumResult)data[index];

            return this;
        }

        public override List<byte> WriteToBytes()
        {
            throw new NotImplementedException();
        }
    }
}